package Test;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;

import RPS.RPSEnum;
import RPS.Result;
import RPS.RockPaperScissors;

public class TestRockPaperScissors {
	
	RockPaperScissors rps;
	

  @BeforeClass
  public void setUpClass() {
	  
	  rps= new RockPaperScissors();
  }
  

  @AfterClass
  public void tearDownClass() {
	  
	  rps=null;
  }
  
  
  // ************************************************** No parameters ************************************************************
  
/*
  @Test
  public void testWinPlay() { 
	 
	  // With no parameters
	  RPSEnum e1= RPSEnum.ROCK;
	  RPSEnum e2= RPSEnum.SCISSORS;
	  Result r =rps.play(e1, e2);
	  Result r2= Result.WIN;
	  assert r.equals(r2);

  }
  
  
  @Test
  public void testTiePlay() {
	  
	// With no parameters
	  RPSEnum e1= RPSEnum.ROCK;
	  RPSEnum e2= RPSEnum.ROCK;
	  Result r =rps.play(e1, e2);
	  Result r2= Result.TIE;
	  assert r.equals(r2); 
	  
  }
  

  @Test
  public void testLostPlay() {
	  
	// With no parameters
	  RPSEnum e1= RPSEnum.SCISSORS;
	  RPSEnum e2= RPSEnum.ROCK;
	  Result r =rps.play(e1, e2);
	  Result r2= Result.LOST;
	  assert r.equals(r2);  

  }*/
  
  // ******************************** Methods with data providers ****************************************************************
 
  @DataProvider(name = "testwin")
  public static Object[][] createWinData() {
      return new Object[][] { {RPSEnum.ROCK,RPSEnum.SCISSORS}, {RPSEnum.SCISSORS,RPSEnum.PAPER}, {RPSEnum.PAPER, RPSEnum.ROCK }};
  }
  
  @Test(dataProvider="testwin")
  public void testWinPlay(RPSEnum p1, RPSEnum p2) { 	 
	  
	//Data providers
	  assert rps.play(p1, p2) == Result.WIN;
  }
  
  
  @DataProvider(name = "testtie")
  public static Object[][] createTieData() {
      return new Object[][] { {RPSEnum.ROCK,RPSEnum.ROCK}, {RPSEnum.SCISSORS,RPSEnum.SCISSORS}, {RPSEnum.PAPER, RPSEnum.PAPER }};
  }
  
  @Test(dataProvider= "testtie")
  public void testTiePlay(RPSEnum p1, RPSEnum p2) {
	  
	  //Data providers
	  assert rps.play(p1, p2) == Result.TIE;
  }
  
  
  @DataProvider(name = "testlost")
  public static Object[][] createLostData() {
      return new Object[][] { {RPSEnum.SCISSORS,RPSEnum.ROCK}, {RPSEnum.PAPER,RPSEnum.SCISSORS}, {RPSEnum.ROCK, RPSEnum.PAPER }};
  }
  
  @Test(dataProvider="testlost")
  public void testLostPlay(RPSEnum p1, RPSEnum p2) { 
	  
	//Data providers
	  assert rps.play(p1,p2) == Result.LOST;
  }
  


}

